﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using Path = System.IO.Path;
using WPF_Preview.PreviewClass;

namespace WPF_Preview
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private string selectedExcelFile;
        string excelFolderPath = Path.Combine(Environment.CurrentDirectory, "测试配方文件夹/工艺配方");
        private ImageWindowManager imageWindowManager = new ImageWindowManager();
        public MainWindow()
        {
            InitializeComponent();
            var excelFileLoader = new ExcelFileLoader(excelFolderPath);

            excelFileLoader.LoadExcelFilesToComboBox(cob_Preview);
            btn_PreView.Click += btn_PreView_Click;
            cob_Preview.SelectedIndex = 0;
            cob_Preview.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            cob_Preview.FontSize = 15;
            cob_Preview.Foreground = new SolidColorBrush(Colors.Blue);
        }

        private async void btn_PreView_Click(object sender, RoutedEventArgs e)
        {
            selectedExcelFile = Path.Combine(excelFolderPath, cob_Preview.SelectedItem.ToString());
            await ExcelPreViewTool.ReadExcelAsync(selectedExcelFile, new List<(int, int, int, string)>() { }, imageWindowManager);
        }
    }
}